﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConnectWithR.precipitation;
using System.ServiceModel;
using ConnectWithR.Discharge;


namespace ConnectWithR
{
    /// <summary>
    /// Class to get different web service connection
    /// </summary>
    class proxy
    {
        /// <summary>
        /// get GHCN soap service client
        /// </summary>
        /// <returns></returns>
        public static precipitation.WaterOneFlowClient getPrecipitationClient()
        {
            BasicHttpBinding binding = new BasicHttpBinding();
            binding.Name = "WaterOneFlow";
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
            binding.MaxReceivedMessageSize = 6655360;
            binding.CloseTimeout = TimeSpan.FromMinutes(11);
            binding.OpenTimeout = TimeSpan.FromMinutes(11);
            binding.ReceiveTimeout = TimeSpan.FromMinutes(11);
            binding.SendTimeout = TimeSpan.FromMinutes(11);
            EndpointAddress remoteAddress = new EndpointAddress("http://hydrodata.info/ghcn/cuahsi_1_1.asmx");
            WaterOneFlowClient client = new WaterOneFlowClient(binding, remoteAddress);
            return client;
        }

        /// <summary>
        /// Get NWIS soap service client
        /// </summary>
        /// <returns></returns>
        public static Discharge.WaterOneFlowSoapClient getDischargeClient()
        {
            BasicHttpBinding binding = new BasicHttpBinding();
            binding.Name = "WaterOneFlowSoap";
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
            binding.MaxReceivedMessageSize = 66655360;
            binding.CloseTimeout = TimeSpan.FromMinutes(11);
            binding.OpenTimeout = TimeSpan.FromMinutes(11);
            binding.ReceiveTimeout = TimeSpan.FromMinutes(11);
            binding.SendTimeout = TimeSpan.FromMinutes(11);
            EndpointAddress remoteAddress = new EndpointAddress("http://river.sdsc.edu/wateroneflow/NWIS/DailyValues.asmx");
            Discharge.WaterOneFlowSoapClient client = new Discharge.WaterOneFlowSoapClient(binding,remoteAddress);
            return client;
        }

        /// <summary>
        /// Get NLDAS soap service client. 
        /// </summary>
        /// <returns></returns>
        public static Evapotranspiration.WaterOneFlowSoapClient getEvapotranspirationClient()
        {
            BasicHttpBinding binding = new BasicHttpBinding();
            binding.Name = "WaterOneFlowSoap";
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
            binding.MaxReceivedMessageSize = 66655360;
            binding.CloseTimeout = TimeSpan.FromMinutes(11);
            binding.OpenTimeout = TimeSpan.FromMinutes(11);
            binding.ReceiveTimeout = TimeSpan.FromMinutes(11);
            binding.SendTimeout = TimeSpan.FromMinutes(11);
            EndpointAddress remoteAddress = new EndpointAddress("http://hydro1.sci.gsfc.nasa.gov/daac-bin/his/1.0/NLDAS_NOAH_002.cgi");
            Evapotranspiration.WaterOneFlowSoapClient client = new Evapotranspiration.WaterOneFlowSoapClient(binding, remoteAddress);
            return client;
        }
    }
}
